﻿using System;
using System.Windows.Automation;

namespace QuickUIT.Controls
{
    /// <summary>
    /// Represents a list item control. 
    /// </summary>
    public class UIListItem : UIBaseControl
    {
        /// <summary>
        /// Gets the current expand collapse state of the control.
        /// If the control does not support the <see cref="ExpandCollapsePattern"/> , returns a null reference.
        /// </summary>
        public new ExpandCollapseState? ExpandCollapseState
        {
            get { return base.ExpandCollapseState; }
        }

        /// <summary>
        /// Gets the toggle state if the list item is checkable. 
        /// </summary>
        public new ToggleState? ToggleState
        {
            get { return base.ToggleState; }
        }

        /// <summary>
        /// Specifies the ordinal number of the column that contains this cell or item.
        /// </summary>
        public new int Column
        {
            get { return base.Column; }
        }

        /// <summary>
        /// Specifies the number of columns spanned by this cell or item.
        /// </summary>
        public new int ColumnSpan
        {
            get { return base.ColumnSpan; }
        }

        /// <summary>
        /// Specifies the ordinal number of the row that contains this cell or item.
        /// </summary>
        public new int Row
        {
            get { return base.Row; }
        }

        /// <summary>
        /// Specifies the number of rows spanned by this cell or item.
        /// </summary>
        public new int RowSpan
        {
            get { return base.RowSpan; }
        }

        /// <summary>
        /// Gets a value that indicates whether the current list item is selected. 
        /// </summary>
        public new bool IsSelected
        {
            get { return base.IsSelected; }
        }

        /// <summary>
        /// Gets the value of item, if it can be edited. 
        /// </summary>
        public new string Value
        {
            get { return base.Value; }
            set { SetValue(value);}
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIListItem"/> class. 
        /// </summary>
        public UIListItem() : base(ControlType.ListItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIListItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UIListItem(UIBaseControl parent) : base(parent, ControlType.ListItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIListItem"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIListItem(string locator) : base(null, ControlType.ListItem, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIListItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIListItem(UIBaseControl parent, string locator) : base(parent, ControlType.ListItem, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIListItem"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIListItem(AutomationElement control) : base(control, ControlType.ListItem)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIListItem"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIListItem(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.ListItem)
        {
        }

        /// <summary>
        /// Expands the list item if possible, displaying all its child nodes, controls or content. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void Expand()
        {
            base.Expand();
        }

        /// <summary>
        /// Collapses the list item if possible, hiding all its child nodes, controls or content. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void Collapse()
        {
            base.Collapse();
        }

        /// <summary>
        /// Scrolls the list item into view. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void ScrollIntoView()
        {
            base.ScrollIntoView();
        }

        /// <summary>
        /// Selects the current list item.
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void Select()
        {
            base.ScrollIntoView();
            base.Select(); 
        }

        /// <summary>
        /// Adds the list item to the current list selection.
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void AddToSelection()
        {
            base.AddToSelection();
        }

        /// <summary>
        /// Removes the list item from the current list selection.
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void RemoveFromSelection()
        {
            base.RemoveFromSelection();
        }

        /// <summary>
        /// Invokes an action on the list item (e.g. double clicking on an item). 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void Invoke()
        {
            base.Invoke();
        }

        /// <summary>
        /// Toggles the list item, if possible. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        /// <remarks>A control will cycle through its ToggleState in this order: On, Off and, if supported, Indeterminate.</remarks>
        public new void Toggle()
        {
            base.Toggle();
        }

        /// <summary>
        /// Toggles on the list item, if possible.
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void ToggleOn()
        {
            base.ToggleOn();
        }

        /// <summary>
        /// Toggles off the list item, if possible. 
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The current element does not exist anymore.</exception>
        public new void ToggleOff()
        {
            base.ToggleOff();
        } 

        /// <summary>
        /// Sets the value of the list item, if it can be edited.
        /// </summary>
        /// <param name="value">The value to set.</param>
        public new void SetValue(string value)
        {
            base.SetValue(value);
        }

        /// <summary>
        /// Gets the parent selection container of the list item. 
        /// </summary>
        /// <returns>The <see cref="AutomationElement"/> of the parent control that implements the <see cref="SelectionPattern"/>.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement GetSelectionContainer()
        {
            return base.GetSelectionContainer();
        }
    }
}
